package clusterapi

import (
	"context"
)

// Manager is the interface for a cluster manager
type Manager interface {
	// Start starts the cluster manager
	Start(ctx context.Context) error
	// Stop stops the cluster manager
	Stop(ctx context.Context) error
	// Join joins the cluster using the provided seed nodes
	Join(ctx context.Context, addresses []string) error
	// Leave leaves the cluster
	Leave(ctx context.Context) error
	// GetLocalNode gets information about the local node
	GetLocalNode(ctx context.Context) (*NodeInfo, error)
	// GetNode gets information about a node
	GetNode(ctx context.Context, nodeID string) (*NodeInfo, error)
	// GetNodes gets information about all nodes
	GetNodes(ctx context.Context) ([]*NodeInfo, error)
	// GetLeader gets information about the leader node
	GetLeader(ctx context.Context) (*NodeInfo, error)
	// IsLeader checks if the local node is the leader
	IsLeader(ctx context.Context) (bool, error)
	// GetMetadata gets metadata
	GetMetadata(ctx context.Context, key string) (string, error)
	// SetMetadata sets metadata
	SetMetadata(ctx context.Context, key string, value string) error
	// DeleteMetadata deletes metadata
	DeleteMetadata(ctx context.Context, key string) error
	// Subscribe subscribes to cluster events
	Subscribe(ctx context.Context, eventType string) (<-chan Event, error)
	// Unsubscribe unsubscribes from cluster events
	Unsubscribe(ctx context.Context, eventType string, ch <-chan Event) error
	// GetCluster returns the underlying cluster implementation
	GetCluster() interface{}
}
